# -*- coding: utf-8 -*-
# @Time         : 13:40 2025/2/26
# @Author       : Chris
# @Description  :
from typing import Optional, List

from .product import ProductType, ProductStatus, Industry, FlashSaleType, StuffStatus, SpecType
from .product_create_callback import PublishStatus

from .._models import BaseModel, NickedStrEnum


class PurpleUnit(NickedStrEnum):
    """单位"""
    DAY = ("天", "天")
    """天"""

    YEAR = ("年", "年")
    """年"""

    MONTH = ("月", "月")
    """月"""


class AdventDataExpire(BaseModel):
    """有效期信息"""
    num: int
    """保质期"""

    unit: PurpleUnit
    """单位"""


class AdventDataProduction(BaseModel):
    """生产信息"""
    date: str
    """生产日期"""


class AdventData(BaseModel):
    """闲鱼特卖信息"""
    expire: AdventDataExpire
    """有效期信息"""

    production: AdventDataProduction
    """生产信息"""


class BookData(BaseModel):
    """图书信息"""
    isbn: str
    """图书ISBN码"""

    title: str
    """图书标题"""

    author: Optional[str] = None
    """图书作者"""

    publisher: Optional[str] = None
    """图书出版社"""


class FluffyUnit(NickedStrEnum):
    """单位"""
    DAY = ("天", "天")
    """天"""


class BrandDataExpire(BaseModel):
    """有效期信息"""
    num: int
    """保质期"""

    unit: FluffyUnit
    """单位"""


class Image(BaseModel):
    """资质证明

    新图片信息
    """
    height: int
    """图片高度"""

    src: str
    """图片地址"""

    width: int
    """图片宽度"""


class BrandDataProduction(BaseModel):
    """生产信息"""
    date: str
    """生产日期"""


class BrandData(BaseModel):
    """品牌捡漏信息"""
    expire: Optional[BrandDataExpire] = None
    """有效期信息"""

    images: Optional[List[Image]] = None
    """资质证明"""

    production: Optional[BrandDataProduction] = None
    """生产信息"""

    supplier: Optional[str] = None
    """供应商名称"""


class ChannelPV(BaseModel):
    """商品属性"""
    property_id: str
    """属性ID"""

    property_name: str
    """属性名称"""

    value_id: str
    """属性值ID"""

    value_name: str
    """属性值名称"""


class FoodDataExpire(BaseModel):
    """食品有效期信息"""
    num: int
    """保质期"""

    unit: PurpleUnit
    """单位"""


class Address(BaseModel):
    """食品生产地信息"""
    city: int
    """生产地城市ID"""

    detail: str
    """详细地址"""

    district: int
    """生产地地区ID"""

    province: int
    """生产地省份ID"""


class FoodDataProduction(BaseModel):
    """食品生产信息"""
    address: Address
    """食品生产地信息"""

    date: str
    """食品生产日期"""


class FoodData(BaseModel):
    """食品信息"""
    brand: str
    """食品品牌"""

    expire: FoodDataExpire
    """食品有效期信息"""

    pack: str
    """食品包装"""

    production: FoodDataProduction
    """食品生产信息"""

    spec: str
    """食品规格"""


class PublishShop(BaseModel):
    """商品发货城市"""
    city: int
    """商品发货城市ID"""

    content: str
    """商品描述, 注意：一个中文按2个字符算，不支持HTML代码，可使用\n换行"""

    district: int
    """商品发货地区ID"""

    images: List[str]
    """商品图片URL, 注意：第一张为商品主图"""

    province: int
    """商品发货省份ID"""

    status: Optional[int] = None
    """使用状态, 枚举值：
    1 : 使用中（表示选中该信息发布到闲鱼）
    2 : 未使用
    """

    title: str
    """商品标题, 注意：一个中文按2个字符算"""

    user_name: str
    """闲鱼会员名"""

    item_id: Optional[int] = None
    """闲鱼商品ID"""

    service_support: Optional[str] = None
    """商品服务"""

    white_images: Optional[str] = None
    """商品白底图URL"""


class BeautyMakeup(BaseModel):
    """美妆信息"""
    brand: str
    """品牌"""

    images: List[str]
    """验货图片"""

    level: str
    """成色"""

    org_id: int
    """检测机构ID, 枚举值：
    181 : 维鉴
    182 : 中检科深
    """

    org_name: str
    """检测机构名称"""

    spec: str
    """规格"""


class Curio(BaseModel):
    """文玩信息"""
    images: List[str]
    """验货图片"""

    material: str
    """材料"""

    org_id: int
    """检测机构ID, 枚举值：
    191 : NGC评级
    192 : PMG评级
    193 : 公博评级
    194 : PCGS评级
    195 : 众诚评级
    196 : 保粹评级
    197 : 华夏评级
    198 : 爱藏评级
    199 : 华龙盛世
    1910 : 国鉴鉴定
    1911 : 信泰评级
    1912 : 闻德评级
    """

    org_name: str
    """检测机构名称"""

    qc_no: str
    """验货编码"""

    size: str
    """尺寸"""


class Game(BaseModel):
    """游戏信息"""
    images: List[str]
    """验货图片"""

    platform: str
    """游戏平台"""

    qc_desc: str
    """验货描述"""

    qc_no: str
    """验货编码"""

    title: str
    """报告标题"""


class Jewelry(BaseModel):
    """珠宝信息"""
    color: str
    """颜色"""

    images: List[str]
    """验货图片"""

    org_name: str
    """检测机构名称"""

    qc_desc: str
    """验货描述"""

    qc_no: str
    """验货编码"""

    shape: str
    """形状"""

    weight: str
    """重量"""


class UsedCar(BaseModel):
    """二手车信息

    OpenProductReportUsedCar
    """
    business_license_front: Optional[str] = None
    """营业执照图片"""

    car_function: Optional[str] = None
    """使用性质 : 营运/非营运"""

    car_vin: Optional[str] = None
    """车辆识别代码VIN码"""

    driving_license_car_photo: Optional[str] = None
    """行驶证车辆页图片"""

    driving_license_info: Optional[str] = None
    """行驶证主页图片"""

    report_url: Optional[str] = None
    """验货报告链接"""


class Valuable(BaseModel):
    """奢品信息"""
    images: List[str]
    """验货图片"""

    org_id: int
    """检测机构ID, 枚举值：
    161 : 中检
    162 : 国检
    163 : 华测
    164 : 中溯
    """

    org_name: str
    """检测机构名称"""

    qc_desc: str
    """验货描述"""

    qc_no: str
    """验货编码"""


class ReportItem(BaseModel):
    """选项描述"""
    answer_desc: str
    """选项描述"""

    answer_id: int
    """选项ID"""

    answer_name: str
    """选项名称"""

    answer_type: int
    """选项类型"""

    category_name: str
    """分类名称"""

    group_name: str
    """分组名称"""

    question_name: str
    """问题名称"""


class Yx3CInfo(BaseModel):
    """严选3c信息"""
    answer_ids: List[int]
    """质检选项ID, 内部存储，不对外展示"""

    brand_id: int
    """品牌ID"""

    brand_name: str
    """品牌名称"""

    class_id: int
    """品类ID"""

    model_id: int
    """机型ID"""

    model_name: str
    """机型名称"""

    model_sn: str
    """IMEI/序列号"""

    report_items: List[ReportItem]
    """质检报告项, 体现在商品验货报告页"""

    report_time: str
    """质检时间, 体现在商品验货报告页"""

    report_user: str
    """质检人, 体现在商品验货报告页"""

    subclass_id: int
    """子类ID"""


class ReportData(BaseModel):
    """验货报告信息"""
    beauty_makeup: Optional[BeautyMakeup] = None
    """美妆信息"""

    curio: Optional[Curio] = None
    """文玩信息"""

    game: Optional[Game] = None
    """游戏信息"""

    jewelry: Optional[Jewelry] = None
    """珠宝信息"""

    used_car: Optional[UsedCar] = None
    """二手车信息"""

    valuable: Optional[Valuable] = None
    """奢品信息"""

    yx_3_c: Optional[Yx3CInfo] = None
    """严选3C信息"""


class SkuImage(BaseModel):
    """规格图片"""
    height: int
    """图片高度"""

    sku_text: str
    """规格属性"""

    src: str
    """图片地址"""

    width: int
    """图片宽度"""


class SkuInfo(BaseModel):
    """SKU信息"""
    price: int
    """SKU售价（分）"""

    stock: int
    """SKU库存"""

    sku_text: Optional[str] = None
    """SKU规格
    格式 : 规格:属性，多个时使用";"拼接。如:颜色:白色;容量:128G
    示例值:
    颜色:黑色;内存:512G
    """

    sku_id: Optional[int] = None
    """管家SKU规格ID"""

    outer_id: Optional[str] = None
    """SKU商家编码"""

    xy_sku_id: Optional[int] = None
    """闲鱼SKUID"""


class ProductDetail(BaseModel):
    """商品详情信息"""
    channel_cat_id: str
    """商品类目ID"""

    item_biz_type: ProductType
    """商品类型"""

    price: int
    """商品售价（分）"""

    product_id: int
    """管家商品ID"""

    product_status: ProductStatus
    """商品状态"""

    publish_status: PublishStatus
    """发布状态, 枚举值：
    -1：不可操作（不可上架/编辑）
    1：草稿箱（可编辑/删除）
    2：待发布（可上架/编辑/删除）
    3：销售中（可下架/编辑）
    4：已下架（可上架/编辑/删除）
    5：已售罄（可上架/编辑/删除）
    9：商品异常（可编辑/删除）
    """

    sold: int
    """商品销量"""

    sp_biz_type: Industry
    """商品行业"""

    stock: int
    """商品库存"""

    title: str
    """商品标题"""

    advent_data: Optional[AdventData] = None
    """闲鱼特卖信息"""

    book_data: Optional[BookData] = None
    """图书信息"""

    brand_data: Optional[BrandData] = None
    """品牌捡漏信息"""

    channel_pv: Optional[List[ChannelPV]] = None
    """商品属性"""

    create_time: Optional[int] = None
    """商品创建时间"""

    detail_images: Optional[List[Image]] = None
    """详情图片"""

    express_fee: Optional[int] = None
    """运费（分）"""

    flash_sale_type: Optional[FlashSaleType] = None
    """闲鱼特卖类型"""

    food_data: Optional[FoodData] = None
    """食品信息"""

    offline_time: Optional[int] = None
    """商品下架时间"""

    online_time: Optional[int] = None
    """商品上架时间"""

    original_price: Optional[int] = None
    """商品原价（分）"""

    outer_id: Optional[str] = None
    """商家编码"""

    publish_shop: Optional[List[PublishShop]] = None
    """发布店铺"""

    report_data: Optional[ReportData] = None
    """验货报告信息"""

    sku_images: Optional[List[SkuImage]] = None
    """规格图片"""

    sku_items: Optional[List[SkuInfo]] = None
    """商品多规格信息"""

    sold_time: Optional[int] = None
    """商品售罄时间"""

    specify_publish_time: Optional[str] = None
    """定时上架时间"""

    stuff_status: Optional[StuffStatus] = None
    """商品成色"""

    update_time: Optional[int] = None
    """商品更新时间"""

    spec_type: Optional[SpecType] = None
    """规格类型"""
